package com.kvest.mobile_newspaper.network.base;

import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;

public class HTTPRequest extends Thread
{
	private HTTPRequestResult resultListener;
	protected HttpClient client;
	protected String url;
	
	public HTTPRequest(String url)
	{
		super();
		
		this.url = url;
		client = new DefaultHttpClient();
		resultListener = null;
	}

	public void setResultListener(HTTPRequestResult resultListener) 
	{
		this.resultListener = resultListener;
	}
	
	protected void result(int code, String result)
	{
		if (resultListener != null)
		{
			resultListener.httResponce(code, result);
		}
	}
	
	@Override
	public void interrupt()
	{
		try
		{
			client.getConnectionManager().shutdown();
		}
		catch(Exception ex){}
		
		super.interrupt();
	}
}
